package ioc05;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/5/16 14:56
 * Version:1.0-SNAPSHOT
 * Description:
 */
public class Test {

    public static void main(String[] args) {
//        SomeService someService = (SomeService) ObjectFactory.getObject();
        ApplicationContext ac = new ClassPathXmlApplicationContext("ioc05/spring.xml");
        SomeService someService = (SomeService) ac.getBean("someService");
        someService.doSome();
        someService.doOther();

        // 练习
        // 使用Spring管理一下的两个bean
//        Map map = System.getenv();
        Map map = (Map) ac.getBean("map");
        System.out.println(map);

//        String javaHome = System.getenv("JAVA_HOME");
        String javaHome = (String) ac.getBean("javaHome");
        System.out.println(javaHome);
    }

}
